<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	template="/templates/masterPage.xhtml">

	<ui:define name="pageHeader">
		<div>
			<h1>Profile</h1>
		</div>
	</ui:define>

	<ui:define name="content">
		<div class="panel">
			<f:event listener="#{profileBean.loadFields(request.remoteUser)}"
				type="preRenderView" />

			<p:tabView orientation="left">

				<p:tab title="Change data">
					<h:form id="changedataform">
						<h:panelGrid columns="2" cellpadding="10">
							<h:outputLabel for="firstName" value="First Name: *" />
							<p:inputText id="firstName" value="#{profileBean.firstName}"
								required="true" label="First Name">
								<f:converter converterId="userInputConverter" />
							</p:inputText>

							<h:outputLabel for="lastName" value="Last Name: *" />
							<p:inputText id="lastName" value="#{profileBean.lastName}"
								required="true" label="Last Name">
								<f:converter converterId="userInputConverter" />
							</p:inputText>

							<h:outputLabel for="email" value="Email: *" />
							<p:inputText id="email" value="#{profileBean.email}"
								required="true" label="Email">
								<f:converter converterId="userInputConverter" />
								<f:validator validatorId="emailValidator" />
							</p:inputText>

							<p:commandButton value="Change data"
								actionListener="#{profileBean.changeUserInfo}"
								update=":feedback, changedataform" />
						</h:panelGrid>
					</h:form>
				</p:tab>

				<p:tab title="Change password/Verify SVN">
					<h:form id="changepassform">
						<h:panelGrid columns="2" cellpadding="10">
							<h:outputLabel for="oldPassword" value="Old password: *" />
							<p:password id="oldPassword" value="#{profileBean.oldPassword}"
								required="true" label="Old password">
								<f:converter converterId="userInputConverter" />
							</p:password>

							<h:outputLabel for="newPassword1" value="New password: *" />
							<p:password id="newPassword1" match="newPassword2"
								value="#{profileBean.newPassword}" required="true"
								label="New password">
								<f:converter converterId="userInputConverter" />
							</p:password>

							<h:outputLabel for="newPassword2" value="Confirm new password: *" />
							<p:password id="newPassword2" value="#{profileBean.newPassword}"
								required="true" label="Confirm new password">
								<f:converter converterId="userInputConverter" />
							</p:password>

							<p:commandButton value="Change password"
								actionListener="#{profileBean.changePassword}" update=":feedback, changepassform" />
						</h:panelGrid>
					</h:form>
					<p:separator/>
					<h:form>
						<p:panel id="verifysvnpanel" style="border: none; padding: 10;">
						<p:commandButton value="Verify SVN"
								actionListener="#{profileBean.verifySVN}" update=":feedback" />
						</p:panel>
					</h:form>
				</p:tab>

			</p:tabView>

			<ui:insert name="feedback">
				<ui:include src="/templates/feedback.xhtml" />
			</ui:insert>
		</div>


	</ui:define>

	<ui:define name="footer">
		<div />
	</ui:define>
</ui:composition>